<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2015/8/27
 * Time: 10:02
 */

vendor("WXPayAPI.lib.JsApiPay");
//请求工具方法
function post($url,$post_string)
{
    $ch = curl_init($url);
    if(isset($post_string)) {
        curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string);
    }
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
    $this_header = array(
        "Content-type: application/x-www-form-urlencoded"
    );
    curl_setopt($ch, CURLOPT_HTTPHEADER, $this_header);
    $data = curl_exec($ch);
    curl_close($ch);
    return $data;
}
//得到JsApiPay实例
function getTools(){
    include_once('WxpayAPI/example/WxPay.JsApiPay.php');
    include_once('WxpayAPI/lib/WxPay.Data.php');
    include_once('WxpayAPI/lib/WxPay.Config.php');
    return new \JsApiPay();
}
//得到openId
function getOpenId(){
    $tools = getTools();
    return $tools -> GetOpenid();
    //return "oNw7mjgP3jvT-g5cjpMyPxwSXNu0";
}
//得到uuid
function getUUIDShort(){
    $queryResult = M() -> query('select uuid_short()');
    return $queryResult[0]['uuid_short()'];
}
